/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.PaymentsSalaryDao;
import com.click.app.model.Employee;
import com.click.app.model.PaymentsSalary;
import com.click.app.model.Salary;
import java.util.Date;
import java.util.List;

/**
 *
 * @author ariel
 */
public class PaymentsSalaryDaoHibernate extends GenericDaoHibernate<PaymentsSalary, Long> implements PaymentsSalaryDao{

    public PaymentsSalaryDaoHibernate() {
        super(PaymentsSalary.class);
    }

    public List<PaymentsSalary> findByDate(Date date) {
        return getHibernateTemplate().find("from PaymentsSalary where datePay=?", date);
    }

    public List<PaymentsSalary> findBySalary(Salary salary) {
        return getHibernateTemplate().find("from PaymentsSalary where salary=?", salary);
    }

    public List<PaymentsSalary> findByEmployee(Employee employee) {
        return getHibernateTemplate().find("from PaymentsSalary where salary.employee=? order by datePay", employee);
    }

    public PaymentsSalary lastPaymentSalary(Employee employee) {
        List<PaymentsSalary> pSs = getHibernateTemplate().find("from PaymentsSalary where salary.employee=? order by datePay", employee);
        return pSs.get(pSs.size() - 1);
    }
}
